//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.meida.module.bus.provider.handler;

import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.meida.common.base.entity.EntityMap;
import com.meida.common.mybatis.interceptor.PageInterceptor;
import com.meida.common.mybatis.model.PageParams;
import com.meida.common.mybatis.model.ResultBody;
import com.meida.common.mybatis.query.CriteriaQuery;
import com.meida.module.pay.client.entity.PayBalanceLog;
import com.meida.module.user.client.entity.AppUser;
import org.springframework.stereotype.Component;

import java.util.List;

@Component("busBalanceLogPageHandler")
public class BusBalanceLogPageHandler implements PageInterceptor<PayBalanceLog> {
    public BusBalanceLogPageHandler() {
    }

    @Override
    public ResultBody validate(CriteriaQuery cq, EntityMap params) {
        return ResultBody.ok();
    }

    @Override
    public void prepare(CriteriaQuery cq, PageParams pageParams, EntityMap params) {
        cq.in("out".equals(params.get("type")), "logType", StrUtil.split("21,31,41", ','));
        cq.in("in".equals(params.get("type")), "logType", StrUtil.split("20,30,40", ','));
        cq.like(ObjectUtil.isNotNull(params.get("userId")), "pbl.userId", params.get("userId"));
        cq.like(ObjectUtil.isNotNull(params.get("fullName")), "user.fullName", params.get("fullName"));
        cq.like(ObjectUtil.isNotNull(params.get("body")), "pbl.body", params.get("body"));
        cq.ge(ObjectUtil.isNotEmpty(params.get("beginDate")), "pbl.createTime", params.get("beginDate"));
        cq.le(ObjectUtil.isNotEmpty(params.get("endDate")), "pbl.createTime", params.get("endDate"));
        cq.eq(ObjectUtil.isNotEmpty(params.get("status")), "pbl.status", params.get("status"));
        cq.ge(ObjectUtil.isNotEmpty(params.get("updateBegin")), "pbl.createTime", params.get("updateBegin"));
        cq.le(ObjectUtil.isNotEmpty(params.get("updateEnd")), "pbl.createTime", params.get("updateEnd"));
        cq.select(AppUser.class, "fullName");
        cq.createJoin(AppUser.class);

    }

    @Override
    public void complete(CriteriaQuery<PayBalanceLog> cq, List<EntityMap> result, EntityMap extra) {

    }
}
